/*
 * HackSQL
 * Copyright (C) 2008-2009
 *
 * Authors: Felipe Nascimento Silva Pena
 *          Gustavo Menezes Oliveira
 *          Henrique Montenegro Decaria
 *          Higor Eurípedes Pimentel Fernandes de Araújo
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef __TYPES_H__
#define __TYPES_H__

#define HACKSQL_DEFAULT_SERVER "localhost"
#define HACKSQL_DEFAULT_PORT   "4225"

typedef enum {
/* 'Wtf' Errors */

	HS_ERROR_UNKNOWN = 0,
	HS_ERROR_UNKNOWN_TABLE,
	HS_ERROR_UNKNOWN_SCHEME,
	HS_ERROR_UNKNOWN_FIELD,
	HS_ERROR_UNKNOWN_COMMAND,
	HS_ERROR_UNKNOWN_FUNCTION,

/* Syntax errors. */

	HS_ERROR_SQL_ERROR,
	HS_ERROR_CONFIG_ERROR,

/* File errors. */
	HS_ERROR_FILE_OPEN,
	HS_ERROR_FILE_READ,
	HS_ERROR_FILE_WRITE,
	HS_ERROR_FILE_NOTFOUND,

/* Internal Errors */

	HS_ERROR_TABLE_ERROR,
	HS_ERROR_SCHEME_ERROR,
	HS_ERROR_ALLOC_ERROR,

/* Number of error codes. */

	HS_ERROR_CODE_COUNT
} hs_errno_t;

#define MAX_RECV_DATA  1024

#define HACKSQL_CMD(name) int cmd_##name (int argc, char **argv, char *raw)

/*
 * A typical command handler function.
 */
typedef int (cmd_func_t) (int, char **, char *);

typedef struct {
	char *name;		/* the command name */
	cmd_func_t *func;	/* a function to call when the command is called */
	char *desc;		/* description */
} command_t;

typedef struct {
	int argc;
	char **argv;
	char *raw;
} command_data_t;


#endif				/* __TYPES_H__ */
